<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use services\models\minisite\MActivityShowFeel;

/* @var $this yii\web\View */
/* @var $model common\models\MActivityShowFeel */
$category = MActivityShowFeel::$CATEGORY;
unset($category[0]);
?>
<div class="mactivity-show-feel-update">
    <div class="mactivity-show-feel-form">

        <?php $form = ActiveForm::begin(['id' => 'ajaxForm']);
            $is_hidden = $model->c_channel == 2 ? '' : 'display:none';
        ?>
	
        <?= $form->field($model, 'c_status')->radioList(MActivityShowFeel::$STATUS) ?>
        <?php  if($model->c_channel == 2):?>
        <?= $form->field($model, 'c_category')->dropDownList($category) ?>
        <?php else :?>
         <?= $form->field($model, 'c_category')->dropDownList($category,['style'=>'display:none'])->label(false) ?>
        <?php endif;?>
        <?= $form->field($model, 'c_score')->radioList([1=>1, 2, 3, 4, 5]) ?>

        <div class="form-group">
            <?= Html::submitButton('审核', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
        </div>

        <?php ActiveForm::end(); ?>

    </div>
    <script>
        jQuery('form#ajaxForm').on('beforeSubmit', function (e) {
            var $form = $(this);
            $.ajax({
                url: $form.attr('action'),
                type: 'post',
                data: $form.serialize(),
                dataType: 'json',
                success: function (data) {
                    $('tr[data-key="' + data.id + '"]').children().last().prev().html(data.status)
                    console.log(data.status)
                    $('#modal').modal('hide')
                }
            });
        }).on('submit', function (e) {
            e.preventDefault();
        });
    </script>

</div>
